﻿Imports System
Imports System.IO
Imports System.Data.OleDb
Imports System.Data
Imports System.Drawing
Imports System.Drawing.Imaging
Namespace Arwani
    Partial Class Backend_AddEditPromoListMaster
        Inherits System.Web.UI.Page

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            If (Session("ADMIN_USER") IsNot Nothing) Then
                If Page.IsPostBack Then Exit Sub
                If Request.QueryString("id") <> "0" Then
                    Call getPromoById(Request.QueryString("id").ToString())
                End If
            Else
                Response.Redirect("Default.aspx")
            End If

        End Sub

        Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
            Dim strQ As String
            'Dim strQckh As String
            Dim arwCon As New ArwaniController

            strQ = "update PromoMaster set Name='" & txtName.Text & "',Description='" & txtDesc.Text & "' where id=" & Val(Request.QueryString("id"))
            arwCon.ExecuteNonQuery(strQ)
            Response.Redirect("PromoListMaster.aspx")


        End Sub


        Public Sub getPromoById(ByVal Id As String)
            Dim arwCon As New ArwaniController
            Dim strQ As String = "select * from PromoMaster where id=" & Id
            Dim dtTable As DataTable = arwCon.ExecuteQuery(strQ)
            If dtTable.Rows.Count > 0 Then
                If Not IsDBNull(dtTable.Rows(0)("Name")) Then Me.txtName.Text = dtTable.Rows(0)("Name")
              
                If Not IsDBNull(dtTable.Rows(0)("Description")) Then Me.txtDesc.Text = dtTable.Rows(0)("Description")

            End If
        End Sub

        Protected Sub btnCancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCancel.Click
            Response.Redirect("PromoListMaster.aspx")
        End Sub
    End Class
End Namespace